<template>
  <div class="admin-login">
    <div class="login-box">
      <div class="header">
        <router-link to="/" class="back-link">
          <el-icon><ArrowLeft /></el-icon>
          返回商城
        </router-link>
        <h2>卖家后台登录</h2>
      </div>
      <el-form :model="loginForm" class="login-form">
        <el-form-item>
          <el-input 
            v-model="loginForm.username" 
            placeholder="请输入商家账号"
            prefix-icon="User"
          />
        </el-form-item>
        <el-form-item>
          <el-input 
            v-model="loginForm.password" 
            type="password" 
            placeholder="请输入密码"
            prefix-icon="Lock"
            show-password
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleLogin" style="width: 100%">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { ElMessage } from 'element-plus';
import { User, Lock, ArrowLeft } from '@element-plus/icons-vue';

const router = useRouter();
const route = useRoute();
const loginForm = ref({
  username: '',
  password: ''
});

const handleLogin = () => {
  if (loginForm.value.username === 'huaaotian' && loginForm.value.password === '10086') {
    localStorage.setItem('adminToken', 'true');
    router.push('/admin/products');
    ElMessage.success('登录成功');
  } else {
    ElMessage.error('账号或密码错误');
  }
};
</script>

<style scoped>
.admin-login {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #f0f2f5;
}

.login-box {
  width: 400px;
  padding: 40px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.header {
  position: relative;
  margin-bottom: 30px;
  text-align: center;
}

.back-link {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  color: #409EFF;
  text-decoration: none;
  font-size: 14px;
}

.back-link:hover {
  color: #66b1ff;
}

h2 {
  text-align: center;
  color: #2c3e50;
}

.login-form {
  margin-top: 20px;
}
</style> 